﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TImSdk;

namespace TImClient1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
            Closed += MainWindow_Closed;

        }

        private void MainWindow_Closed(object sender, EventArgs e)
        {
            TImSdkService.GetInstance.UnInitTImSdk();
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var path2 = $@"C:\Users\10613\AppData\Roaming\ELabMC\13047558100\voice\1111.mp4";
            MediaPlayer media = new MediaPlayer();
            media.Open(new Uri(path2));
            

                                        var path = $@"C:\Users\10613\AppData\Roaming\ELabMC\13047558100\voice\1111.jpg";
            if (File.Exists(path))
            {
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.CacheOption = BitmapCacheOption.OnLoad;
                bitmap.StreamSource = new MemoryStream(File.ReadAllBytes(path));
                bitmap.EndInit();
                bitmap.Freeze();
            }

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var result = TImSdkService.GetInstance.InitTImSdk();
             result = TImSdkService.GetInstance.Login(UserId.Text,"");
            if (result.Code == 0)
            {
             
                Result.Text = Result.Text + result.Message.ToString();
            }
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            //var result = TImSdkService.IMConvCreate("13047558100", TIMConvType.kTIMConv_C2C, null);
            //Result.Text = Result.Text + result.ToString();
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            TImSdkService.GetInstance.UnInitTImSdk();
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            TImSdkService.GetInstance.TIMFriendshipGetFriendProfileList();
        }
    }
}
